package com.eve.eplus.common.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.eve.eplus.R;
import com.eve.eplus.common.app.Constants;

public class SendMsgAccountListAdapter extends BaseAdapter
{
    private Context mContext;
    private ArrayList<HashMap<String,String>> mData;
    private LayoutInflater mInflater;
    
    public SendMsgAccountListAdapter(Context context,ArrayList<HashMap<String,String>> data){
        this.mContext=context;
        this.mData=data;
        
        this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    
    /*
     * 强制刷新数据
     */
    public void reflash(ArrayList<HashMap<String,String>> data) {
        mData=data;
        notifyDataSetChanged();
    }

    @Override
    public int getCount()
    {
        // TODO Auto-generated method stub
        return mData.size();
    }

    @Override
    public Object getItem(int position)
    {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position)
    {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        ViewHolder holder=null;
        if (convertView == null)
        {
            convertView = mInflater.inflate(R.layout.activity_sendmsg_main_lvitem, null);
            holder = new ViewHolder();
            holder.tvName = (TextView) convertView.findViewById(R.id.item_name);
            holder.imgLogo = (ImageView) convertView.findViewById(R.id.item_image);
            holder.tvId = (TextView) convertView.findViewById(R.id.item_id);
            holder.rlBg = (RelativeLayout) convertView.findViewById(R.id.id_item_account);
            holder.imgSelect = (ImageView) convertView.findViewById(R.id.item_check);

            convertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) convertView.getTag();
        }
        
        holder.tvName.setText(mData.get(position).get(Constants.SNS_ACCOUNT_NAME).toString());
        holder.tvId.setText(mData.get(position).get(Constants.SNS_UID).toString());
        
        //holder.rlBg  账户即将过期标示   提供更新按钮
        return convertView;
    }
    
    private static class ViewHolder{
        TextView tvName;   //名称
        TextView tvId;   //id
        ImageView imgLogo;   //标识
        RelativeLayout rlBg;  //背景
        ImageView imgSelect; //选择
    }

}
